home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: news.sprintlink.net!eskimo!scs
- From: scs@eskimo.com (Steve Summit)
- Subject: Re: Converting Strings to Upper Case
- X-Nntp-Posting-Host: eskimo.com
- Message-ID: <DoMIoI.9IG@eskimo.com>
- Sender: news@eskimo.com (News User Id)
- Organization: schmorganization
- References: <4ifra6$52i@scipio.cyberstore.ca> <DoFA24.AL7@iquest.net> <4ii1nh$bng@castle.nando.net>
- Date: Thu, 21 Mar 1996 15:21:53 GMT
-
- In article <DoFA24.AL7@iquest.net>, dlmiller@iquest.net (Doug or Rose Miller)
- wrote:
- > for (p = test; *p; *p++)
- > if (isalpha(*p)) *p ^= 0x20; /* for ascii machines e.g. PC; use 0x40 for ebcdic machines e.g. IBM mainframe */
-
- Besides the problems which Bill McCarthy has already pointed out,
- I wonder why you're using that needlessly machine-dependent
- expression? If you're going to use isalpha() out of <ctype.h>,
- why not also use toupper()?
-
- As a general rule, any time you can replace
-
- #ifdef machine_a
- x = machine_a_dependent_expression;
- #else
- #ifdef machine_b
- x = machine_b_dependent_expression;
- #else
- #error "Which machine is this?"
- #endif
- #endif
-
- with
-
- x = portable_expression;
-
- it's a win in my book.
-
- Steve Summit
- scs@eskimo.com
- --
- The Communications Decency Act within the Telecommunications Act
- of 1996 (U.S.) is an annoying, threatening, abusive, indecent,
- and obscene piece of legislation which attempts to ban annoying,
- threatening, abusive, indecent, or obscene communication.
-